<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
    <style>
        * {
            margin: 0;
            padding: 0;
        }

        .wrap {
            border: 1px solid #ccc;
            position: absolute;
            left: 100px;
            top: 100px;
            height: 300px;
            width: 1000px;
        }

        .wrap div {

            width: 100px;
            height: 100px;
            position: relative;
            float: left;
            left: 0;
            top: 0;
            text-align: center;
            line-height: 100px;
            border: 1px solid #ccc;
        }
    </style>
</head>

<body>
    <div class="wrap">
        <div class="one">1</div>
        <div class="one">2</div>
        <div class="one">3</div>
        <div class="one">4</div>
        <div class="one">5</div>
    </div>
    <script>
        var wrap = document.querySelector(".wrap"),
            el,
            pos = null,
            flag = false;
        wrap.addEventListener("mousedown", function (e) {
            if (e.target.className === "one") {
                el = e.target;
                pos = {
                    x: e.offsetX,
                    y: e.offsetY,
                }
                flag = true
            }
        })
        document.addEventListener("mousemove", function (e) {
            if (flag) {
                el.style.left = e.pageX - wrap.offsetLeft - pos.x + "px";
                el.style.top = e.pageY - wrap.offsetTop - pos.y + "px";
            }
        })
        document.addEventListener("mouseup", function () {
            flag = false;
        })

    </script>
</body>

</html>